# c_toolchain.cmake - Example Toolchain File for C Purity Test

# 1. Set the target system name. "Generic" is often used for custom/embedded targets.
set(CMAKE_SYSTEM_NAME Generic)

# 2. Specify the C compiler. 
#    Using clang because '--target' is a clang flag.
set(CMAKE_C_COMPILER /home/raymond/p/oh/prebuilts/clang/ohos/linux-x86_64/llvm/bin/clang)

# 3. Set compiler flags. This is where you add the --target flag.
set(CMAKE_C_FLAGS "--target=aarch64-linux-ohos" CACHE STRING "C compiler flags")

# 4. (Optional) Set the C++ compiler to avoid CMake trying to auto-detect a potentially incompatible one.
set(CMAKE_CXX_COMPILER /home/raymond/p/oh/prebuilts/clang/ohos/linux-x86_64/llvm/bin/clang)
set(CMAKE_CXX_FLAGS "--target=aarch64-linux-ohos" CACHE STRING "CXX compiler flags")

# 5. Skip the linker check for the toolchain verification.
#    For embedded systems where libc is not readily available, CMake's default
#    check (which tries to link an executable) will fail.
#    Setting CMAKE_TRY_COMPILE_TARGET_TYPE to STATIC_LIBRARY tells CMake to
#    only try building a static library (.a), which involves no linking.
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
